<?php
    include 'base.php';
    $username = $_POST['username'];
    $password = $_POST['password'];
    // $name = '123456';
    // $word = '123456';
    $sql = "INSERT INTO `user` ( `username`, `password`) VALUES('$username','$password')";
    $res=$conn->query($sql);

    // echo json_encode($res);
    // 查到返回一条数据
    // $row = $res->fetch_assoc();

    if ($res) {
        // 成功
        echo json_encode(Array(
            'code' => 0,
            'msg' => '注册成功',
            'token' => '9832ijds9h239hoejf0h9239h9eh923i320h'
        ));
    } else {
        // 失败
        echo json_encode(Array(
            'code' => 1,
            'msg' => '注册失败',
            'token' => ''
        ));
    }
?>